<template>
  <div class="link">
    <div class="block">
      <h2>友链</h2>
      <p>
        请在<span @click="$router.push('/message')">留言区</span
        >按照以下格式申请友链
      </p>
      <p>名称：百度</p>
      <p>链接地址：https://baidu.com</p>
      <p>图片地址：https://baidu.com/favicon.ico</p>
      <p>描述：绝代天骄，风华正茂</p>
    </div>
    <div class="block2">
      <el-row :gutter="20" v-if="linkData && linkData.length > 0">
        <el-col :lg="8" :md="12" v-for="item in linkData" :key="item._id">
          <a class="link_item" :href="item.linkUrl" target="_block">
            <img :src="item.imgUrl" alt="" />
            <div class="lint_info">
              <h4>{{ item.name }}</h4>
              <div class="link_desc">
                <p>{{ item.desc }}</p>
              </div>
            </div>
          </a>
        </el-col>
      </el-row>
      <el-empty v-else description="暂无友链"></el-empty>
    </div>
  </div>
</template>

<script>
export default {
  name: "link",
  components: {},
  data() {
    return {
      linkData: [],
    };
  },
  methods: {
    async getLinkList() {
      let { data } = await this.$axios({
        methid: "GET",
        url: "/getData/getLinkData",
      });
      this.linkData = data.data;
    },
  },
  created() {
    this.getLinkList();
  },
  mounted() {},
};
</script>

<style lang="less" scoped>
.link {
  .block,
  .block2 {
    background: #fff;
    padding: 20px;
    margin-bottom: 20px;
  }
  .block {
    h2 {
      margin-bottom: 15px;
      font-size: 20px;
      letter-spacing: 3px;
      line-height: 24px;
      border-left: 5px solid #73b899;
      text-indent: 10px;
    }
    p {
      text-indent: 2em;
      color: #444;
      font-size: 14px;
      letter-spacing: 4px;
      line-height: 30px;
      span {
        color: lightcoral;
        letter-spacing: 2px;
        padding: 0 10px;
        cursor: pointer;
      }
    }
    .inputText {
      margin: 15px 0;
    }
  }

  .block2 {
    .link_item {
      display: flex;
      align-items: center;
      width: 100%;
      height: 70px;
      border-radius: 20px;
      box-sizing: border-box;
      padding: 0 8px;
      margin-bottom: 20px;
      -webkit-user-select: none;
      -ms-user-select: none;
      user-select: none;
      transition: all 0.2s;
      background-color: #bfe2e6;
      img {
        width: 55px;
        height: 55px;
        border-radius: 14px;
      }
      .lint_info {
        margin-left: 6px;
        h4 {
          font-size: 17px;
          color: #000;
          width: 190px;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          word-break: break-all;
        }
        .link_desc {
          display: flex;
          align-items: center;
          height: 32px;
          p {
            font-size: 12px;
            line-height: 16px;
            color: #555;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }
        }
      }
    }
  }
}
</style>